package cn.wolfcode.car.business.service.impl;

import cn.wolfcode.car.business.domain.Appointment;
import cn.wolfcode.car.business.domain.StatementItem;
import cn.wolfcode.car.business.mapper.AppointmentMapper;
import cn.wolfcode.car.business.mapper.StatementItemMapper;
import cn.wolfcode.car.business.query.StatementItemQuery;
import cn.wolfcode.car.business.service.IStatementItemService;
import cn.wolfcode.car.common.base.page.TablePageInfo;
import cn.wolfcode.car.common.exception.BusinessException;
import cn.wolfcode.car.common.util.Convert;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
@Transactional
public class StatementItemServiceImpl implements IStatementItemService {

    @Autowired
    private StatementItemMapper StatementItemMapper;

    @Autowired
    private AppointmentMapper appointmentMapper;


    @Override
    public TablePageInfo<StatementItem> query(StatementItemQuery qo) {
        PageHelper.startPage(qo.getPageNum(), qo.getPageSize());
        return new TablePageInfo<StatementItem>(StatementItemMapper.selectForList(qo));
    }


    @Override
    public void save(StatementItem StatementItem) {
        StatementItemMapper.insert(StatementItem);
    }

    @Override
    public StatementItem get(Long id) {
        return StatementItemMapper.selectByPrimaryKey(id);
    }


    @Override
    public void update(StatementItem StatementItem) {


        StatementItemMapper.updateByPrimaryKey(StatementItem);
    }

    @Override
    public void deleteBatch(String ids) {
        Long[] dictIds = Convert.toLongArray(ids);
        for (Long dictId : dictIds) {
            StatementItemMapper.deleteByPrimaryKey(dictId);

        }
    }

    @Override
    public List<StatementItem> list() {
        return StatementItemMapper.selectAll();
    }

   @Override
    public boolean checkNameExsit(String name) {
        return StatementItemMapper.selectByName(name) != null;
    }


}
